package codingforgreat.lchot150;

import java.util.Stack;

public class Lc155 {
    class MinStack {
        Stack<Integer> stack ;
        Stack<Integer> minStack ;

        public MinStack() {
            stack = new Stack<>();
            minStack = new Stack<>();
        }

        public void push(int val) {
            stack.push(val);
            if(minStack.isEmpty() ||  val < minStack.peek()){
                minStack.push(val);
            }else{
                minStack.push( minStack.peek());
            }
        }

        public void pop() {
            minStack.pop();
            stack.pop();

        }

        public int top() {
            return stack.peek();

        }

        public int getMin() {
            return minStack.peek();

        }
    }
}
